const Generator = require('yeoman-generator');
module.exports = class extends Generator{  // yo whj命令
  prompting(){
    return this.prompt([
      {
        type: 'input',
        name:'name',
        message:'your title?',
        default : this.appname
      }
    ])
     .then(answers=>{
       // answer=>{name:""}
       this.answers = answers
     })
  }
  writing(){
    // this.fs.write(
    //  this.destinationPath('temp.txt'),
    //  Math.random().toString()
    // )

    // 模板文件路径
    const tmpls = ['a.css','a.js','a.html','foo.txt'];
    tmpls.forEach(item=>{
      this.fs.copyTpl(
        this.templatePath(item),
        this.destinationPath(item),
        this.answers
      );
    });
  }
};